package com.zh.flowable.config;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.web.client.RestTemplate;

@Configuration
public class FlowableConfig {

    @Value("${empDataSource.url}")
    private String jdbcUrl;
    @Value("${empDataSource.username}")
    private String username;
    @Value("${empDataSource.password}")
    private String password;
    @Value("${empDataSource.driver-class-name}")
    private String driverClassName;

    @Bean
    public NamedParameterJdbcTemplate empJdbcTemplate() {
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setJdbcUrl(jdbcUrl);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        dataSource.setDriverClassName(driverClassName);
        return new NamedParameterJdbcTemplate(dataSource);
    }


    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
